# Programs, flags, etc.
ASM		= nasm
DASM		= ndisasm
CC		= gcc -march=i486
AS		= as
LD		= ld
AR		= ar
CPP		= gcc -E -nostdinc -I../include
ASMFLAGS	= -f elf
CFLAGS		= -Wall -finline-functions -fno-stack-protector -nostdinc -I../include
LDFLAGS		= -r
ARFLAGS		= rcs

.c.o:
	$(CC) $(CFLAGS)	-c -o $*.o $<
.S.o:
	$(CC) $(CFLAGS)	-c -o $*.o $<
.s.o:
	$(ASM) $(ASMFLAGS) -o $*.o $<
.c.S:
	$(CC) $(CFLAGS) -S -o $*.S $<

# This Program
TARGET		= lib.a
OBJS		= errno.o \
		  string.o\
		  klib.o \
		  printk.o \
		  ulib.o

# All Phony Targets
.PHONY : all clean dep

# Default starting position
all : $(TARGET)

$(TARGET) : $(OBJS) 
	$(AR) $(ARFLAGS) $(TARGET) $(OBJS)

clean :
	rm -f $(TARGET) $(OBJS) tmp_make

dep:
	sed '/\#\#\# Dependencies/q' < Makefile > tmp_make
	(for i in *.c;do $(CPP) -M $$i;done) >> tmp_make
	cp tmp_make Makefile
	rm tmp_make

### Dependencies:
errno.o: errno.c
printk.o: printk.c ../include/string.h
string.o: string.c ../include/string.h
ulib.o: ulib.c ../include/cosstd.h ../include/cos/ipc.h \
  ../include/cos/kernel.h ../include/unistd.h
